package com.homedo.distributed.id.client.gen;

import com.homedo.distributed.id.client.gen.constants.GenTypeConstants;
import com.homedo.distributed.id.client.gen.service.GenBufferService;

public abstract class IdGen {

    private static GenBufferService genBufferService = GenBufferService.getInstance();

    /**
     * 根据业务标志获取对应分布式ID主键 -- 有序主键
     *
     * @param bizTag 业务标志
     * @return
     */
    public static String regularity(String bizTag) {
        return regularity(bizTag, 0);
    }

    public static String regularity(String bizTag, int initCacheSize) {
        return genBufferService.gen(bizTag, GenTypeConstants.ID_REGULARITY, initCacheSize);
    }


    /**
     * 根据业务标志获取对应分布式ID主键 -- 无序主键
     *
     * @param bizTag 业务标志
     * @return
     */
    public static String irregularity(String bizTag) {
        return irregularity(bizTag, 0);
    }

    public static String irregularity(String bizTag, int initCacheSize) {
        return genBufferService.gen(bizTag, GenTypeConstants.ID_IRREGULARITY, initCacheSize);
    }

}
